# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
# Contributor: Jan de Groot <jgc@archlinux.org>
# Contributor: DrZaius <lou[at]fakeoutdoorsman[dot]com>
# Contributor: pumbur

pkgbase=opus
pkgname=(
  opus
  opus-docs
)
pkgver=1.4
pkgrel=1
pkgdesc="Totally open, royalty-free, highly versatile audio codec"
url="https://www.opus-codec.org/"
arch=(loong64 x86_64)
license=(BSD)
depends=(
  glibc
)
makedepends=(
  doxygen
  git
  meson
)
_commit=82ac57d9f1aaf575800cf17373348e45b7ce6c0d  # tags/v1.4^0
source=("git+https://github.com/xiph/opus#commit=$_commit")
b2sums=('SKIP')

pkgver() {
  cd opus
  git describe --tags | sed 's/^v//;s/[^-]*-g/r&/;s/-/+/g'
}

prepare() {
  cd opus
}

build() {
  local meson_options=(
    -D asm=disabled
    -D custom-modes=true
    -D rtcd=disabled
    -D intrinsics=disabled
  )

  arch-meson opus build "${meson_options[@]}"
  meson compile -C build
}

check() {
  meson test -C build --print-errorlogs
}

package_opus() {
  provides=(libopus.so)

  meson install -C build --destdir "$pkgdir"
  install -Dt "$pkgdir/usr/share/aclocal" -m644 opus/opus.m4

  install -Dt "$pkgdir/usr/share/licenses/$pkgname" -m644 opus/COPYING

  mkdir -p doc/usr/share
  mv {"$pkgdir",doc}/usr/share/doc
}

package_opus-docs() {
  pkgdesc+=" (documentation)"
  depends=()

  mv doc/* "$pkgdir"
}

# vim:set sw=2 sts=-1 et:
